home *** CD-ROM | disk | FTP | other *** search
- /**********************************************************
- * *
- * (C) Copyright 2002 - 2004, Human Concepts (tm) *
- * *
- ***********************************************************
- * File name: profilePage.js *
- * Author: Andrey Ponomarev *
- **********************************************************/
-
- window.onload = doInit;
-
- function Initialize()
- {
- if( ListObject != null )
- return;
- var width = parseInt(document.body.clientWidth);
- var col = parseInt(width) / 3;
- ListObject = new ListCtrl(document.body);
- ListObject.AddColumn("<b>Field</b>");
- ListObject.AddColumn("<b>Value</b>");
- ListObject.Columns[0].SetWidth( col );
- ListObject.Columns[1].SetWidth( width - col );
- ListObject.HighlightColor = "#CCCCFF";
- }
-
- function doInit()
- {
- Initialize();
-
- var obj = top.hcMain
- if ( typeof (obj) == "object" && typeof (obj.onNavigatePageInit) != "undefined" )
- obj.onNavigatePageInit()
- }
-
- function clearPage()
- {
- ListObject.ClearTable();
- ListObject.RemoveAll();
- }
-
- function LoadOldProfile(group)
- {
- if( typeof( group ) != "object" )
- return;
-
- var ancObjs = group.getElementsByTagName("a")
- for (i = 0; i < ancObjs.length; i++)
- {
- if( ancObjs(i).name != "Profile")
- continue;
-
- var paramObjs = ancObjs(i).getElementsByTagName("param")
- for (j = 0; j < paramObjs.length; j++)
- {
- var obj = paramObjs(j)
- var str = obj.name
- if (typeof(str) != "undefined" )
- {
- var strValue = ""
- if ( typeof (obj.value) != "undefined" )
- strValue = obj.value
-
- // if (!bImageFlag && isEmail(strValue))
- // strValue = "<a href='mailto:" + strValue + "'>" + strValue + "</a>";
- if( typeof(obj.IsPicture) != 'undefined' && obj.IsPicture == "true" && strValue != "" && strValue != " ")
- strValue = "<img src='" + strValue + "'/>";
-
- var newRow = null;
- newRow = new Array( new ListCtlCell(str, 1), new ListCtlCell(strValue, 1) );
- ListObject.Add( newRow );
- }
- } //for
- break;
- } //for
- };
-
- function fillPage(group)
- {
- if( ListObject == null )
- Initialize();
- debugger;
-
- clearPage()
-
- var ProfileData = top.hcMain.getProfilesObj();
-
- if( typeof( group ) != "object" )
- return;
-
- var oProfile = ProfileData.children[0];
-
- if( typeof( oProfile.type ) != 'undefined' && parseInt( oProfile.type ) == 2 && g_gIEVer == 60 )
- {
- ShowHTMLProfile( oProfile, group );
- return;
- }
-
- var oData = top.hcPersons.document.all[ group.id ];
-
- if( oData == null ) return;
- if( typeof( oProfile.type ) != 'undefined' && parseInt( oProfile.type ) == 2 && g_gIEVer < 60 )
- LoadOldProfile(group);
- else
- {
- if( typeof( oProfile.ShowGrid) == 'undefined' || oProfile.ShowGrid == 1 || oProfile.ShowGrid == "1" )
- ListObject.ShowGrid( true );
- else
- ListObject.ShowGrid( false );
-
- for( var i = 0; i < oProfile.children.length; ++i )
- {
- var oParam = oProfile.children[i];
-
- if( oParam.tagName != "PARAM" )
- continue;
-
- var leftText = oParam.Name;
-
- if( typeof( oParam.LeftWordWrap ) != 'undefined' && (oParam.LeftWordWrap == 0 || oParam.LeftWordWrap == "0") )
- leftText = "<NOBR>" + leftText + "</NOBR>";
-
- if( typeof( oParam.LeftStyle ) != 'undefined' )
- leftText = oParam.LeftStyle + leftText + "</font>";
-
- var rightText;
- if( typeof( oParam.FieldId ) != 'undefined' )
- {
- groupValue = oData.children[fi];
- for( var fi = 0; fi < oData.children.length; ++fi )
- if( oData.children[fi].tagName == "PARAM" && oData.children[fi].id == oParam.FieldId )
- {
- groupValue = oData.children[fi];
- break;
- };
-
- rightText = groupValue.name;
- if( typeof( oParam.IsPicture ) != 'undefined' && oParam.IsPicture == 1 && rightText != "" )
- rightText = "<img src=\"" + rightText + "\">";
-
- if( typeof( oParam.IsLink ) != 'undefined' && oParam.IsLink == 1 )
- {
- var strURL = groupValue.value;
- if( typeof( strURL ) == 'undefined' )
- strURL = groupValue.name;
-
- if( strURL.search('@') > 0 )
- strURL = "mailto:" + strURL;
-
- rightText = "<a href='javascript:void(0)' onclick=\"window.open('" + strURL + "')\">" + rightText + "</a>";
- }
- }
- else
- {
- if( typeof( oParam.RightText ) == 'undefined' )
- continue;
-
- rightText = oParam.RightText;
- };
-
- if( typeof( oParam.RightWordWrap ) != 'undefined' && (oParam.RightWordWrap == 0 || oParam.RightWordWrap == "0") )
- rightText = "<NOBR>" + rightText + "</NOBR>";
-
- if( typeof( oParam.RightStyle ) != 'undefined' )
- rightText = oParam.RightStyle + rightText + "</font>";
-
- var newRow = null;
- if( typeof( oParam.Merged ) == 'undefined' || (oParam.Merged != true && oParam.Merged != "true" ) )
- newRow = new Array( new ListCtlCell(leftText, 1), new ListCtlCell(rightText, 1) );
- else
- newRow = new Array( new ListCtlCell(rightText, 2) );
-
- ListObject.Add( newRow );
- };
- };
-
- if( typeof(ListObject.table) == 'undefined' || ListObject.table == null)
- ListObject.Create(document.body);
- else
- ListObject.Show();
- }
-
- function ShowHTMLProfile( p_oProfile, p_oGroup )
- {
- if( typeof( p_oGroup ) != "object" )
- return;
- if( typeof( p_oProfile.url ) == 'undefined' )
- return;
-
- var iFrame = window.frames.hcHTMLProfile;
- if( iFrame == null )
- {
- var frm = document.createElement( "<iframe onload=\"PrepareHtml('" + p_oGroup.id + "');\" name=\"hcHTMLProfile\" width=0 scrolling='no' border='0' frameborder='0' noresize topmargin='0' leftmargin='0' marginheight='0' marginwidth='0'></iframe>")
- document.body.appendChild( frm );
- frm.src = p_oProfile.url;
- }
- }
-
- function PrepareHtml( p_iID )
- {
- var oData = top.hcPersons.document.all[ p_iID ];
- var FieldDefs = top.hcMain.getFieldsObj();
- if( FieldDefs == null ) return;
- var iFrame = window.frames.hcHTMLProfile;
- var html = iFrame.document.body.innerHTML;
-
- for( var i = 0; i < FieldDefs.children.length; ++i )
- {
- var templateName = "\\[@" + FieldDefs.children[i].name + "@\\]";
- for( var fi = 0; fi < oData.children.length; ++fi )
- if( oData.children[fi].tagName == "PARAM" && oData.children[fi].id == FieldDefs.children[i].id )
- {
- groupValue = oData.children[fi];
- break;
- };
-
- html = html.replace( new RegExp( templateName, "g"), groupValue.name );
- }
- document.body.innerHTML = html;
-
- var oImagesCollection = document.body.getElementsByTagName("IMG");
- if( typeof(oImagesCollection) == 'undefined' || oImagesCollection == null )
- return;
-
- for( var i = 0; i < oImagesCollection.length; ++i )
- {
- oImagesCollection[i].onerror = ImageHider;
- }
- }
-
- function ImageHider()
- {
- event.srcElement.style.visibility = "hidden";
- };
-